Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SurfaceMountingManager leaking views from stopped surfaces #37964

Closed
wants to merge 1 commit into from

Conversation

javache
Copy link
Member

@javache javache commented Jun 19, 2023

Summary:
When a Surface is stopped, we don't immediately destroy the SurfaceMountingManager but instead just tear down its internal state. This allows for better error handling (eg did this react tag ever exist, or is this non-existing tag).

The way we construct the set of tags post-deletion is flawed though: mTagToViewState.keySet() does not create a new Set with all the tags used, but instead uses the underlying HashMap to iterate over the keys as needed. This effectively keeps all the Views inside that deleted surface alive.

Changelog: [Android][Fixed] Surfaces in the new architecture no longer leak views once stopped

Differential Revision: D46840717

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner fb-exported labels Jun 19, 2023
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46840717

javache added a commit to javache/react-native that referenced this pull request Jun 20, 2023
…ook#37964)

Summary:
Pull Request resolved: facebook#37964

When a Surface is stopped, we don't immediately destroy the SurfaceMountingManager but instead just tear down its internal state. This allows for better error handling (eg did this react tag ever exist, or is this non-existing tag).

The way we construct the set of tags post-deletion is flawed though: `mTagToViewState.keySet()` does not create a new Set with all the tags used, but instead uses the underlying HashMap to iterate over the keys as needed. This effectively keeps all the Views inside that deleted surface alive.

Changelog: [Android][Fixed] Surfaces in the new architecture no longer leak views once stopped

Reviewed By: sammy-SC, rshest

Differential Revision: D46840717

fbshipit-source-id: aafab0e550bdfd19e561e282c5baba81e97d2082
@javache javache force-pushed the export-D46840717 branch from 577befc to 6a6ab6a Compare June 20, 2023 10:53
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46840717

javache added a commit to javache/react-native that referenced this pull request Jun 20, 2023
…ook#37964)

Summary:
Pull Request resolved: facebook#37964

When a Surface is stopped, we don't immediately destroy the SurfaceMountingManager but instead just tear down its internal state. This allows for better error handling (eg did this react tag ever exist, or is this non-existing tag).

The way we construct the set of tags post-deletion is flawed though: `mTagToViewState.keySet()` does not create a new Set with all the tags used, but instead uses the underlying HashMap to iterate over the keys as needed. This effectively keeps all the Views inside that deleted surface alive.

Changelog: [Android][Fixed] Surfaces in the new architecture no longer leak views once stopped

Reviewed By: sammy-SC, rshest

Differential Revision: D46840717

fbshipit-source-id: 9fca7af8ec43be410655c747ac6915d0e1f169b3
@javache javache force-pushed the export-D46840717 branch from 6a6ab6a to 59a9f36 Compare June 20, 2023 11:12
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46840717

@analysis-bot
Copy link

analysis-bot commented Jun 20, 2023

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,955,354 +220
android hermes armeabi-v7a 8,216,548 +218
android hermes x86 9,469,020 +210
android hermes x86_64 9,311,483 +217
android jsc arm64-v8a 9,516,280 +34
android jsc armeabi-v7a 8,654,801 +28
android jsc x86 9,600,825 +38
android jsc x86_64 9,847,394 +35

Base commit: 936936c
Branch: main

javache added a commit to javache/react-native that referenced this pull request Jun 20, 2023
…ook#37964)

Summary:
Pull Request resolved: facebook#37964

When a Surface is stopped, we don't immediately destroy the SurfaceMountingManager but instead just tear down its internal state. This allows for better error handling (eg did this react tag ever exist, or is this non-existing tag).

The way we construct the set of tags post-deletion is flawed though: `mTagToViewState.keySet()` does not create a new Set with all the tags used, but instead uses the underlying HashMap to iterate over the keys as needed. This effectively keeps all the Views inside that deleted surface alive.

Changelog: [Android][Fixed] Surfaces in the new architecture no longer leak views once stopped

Reviewed By: sammy-SC, rshest

Differential Revision: D46840717

fbshipit-source-id: 925cd526e79ed9152ee0c1b289cded50163c1393
@javache javache force-pushed the export-D46840717 branch from 59a9f36 to e6bb7af Compare June 20, 2023 15:49
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46840717

…ook#37964)

Summary:
Pull Request resolved: facebook#37964

When a Surface is stopped, we don't immediately destroy the SurfaceMountingManager but instead just tear down its internal state. This allows for better error handling (eg did this react tag ever exist, or is this non-existing tag).

The way we construct the set of tags post-deletion is flawed though: `mTagToViewState.keySet()` does not create a new Set with all the tags used, but instead uses the underlying HashMap to iterate over the keys as needed. This effectively keeps all the Views inside that deleted surface alive.

Changelog: [Android][Fixed] Surfaces in the new architecture no longer leak views once stopped

Reviewed By: sammy-SC, rshest

Differential Revision: D46840717

fbshipit-source-id: 582e55203ae706e6c86eec1f34ad42b10abd50f6
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D46840717

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in c16e993.

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Jun 20, 2023
@javache javache deleted the export-D46840717 branch June 20, 2023 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants